package Igor_Dominiak;

public class LiczbaZespolona {

	private double im, re;

	public LiczbaZespolona() {
		im = 0;
		re = 0;
	}

	public LiczbaZespolona(double x) {
		im = x;
		re = x;
	}

	public LiczbaZespolona(double re, double im) {
		this.im = im;
		this.re = re;
	}
	
	public LiczbaZespolona(LiczbaZespolona z){
		im = z.im;
		re = z.re;
	}

	public double getIm() {
		return im;
	}

	public void setIm(double im) {
		this.im = im;
	}

	public double getRe() {
		return re;
	}

	public void setRe(double re) {
		this.re = re;
	}

	public LiczbaZespolona suma(LiczbaZespolona z1, LiczbaZespolona z2) {
		double r = 0, i = 0;
		r = z1.getRe() + z2.getRe();
		i = z1.getIm() + z2.getIm();
		LiczbaZespolona z = new LiczbaZespolona(r, i);
		return z;
	}

	public LiczbaZespolona roznica(LiczbaZespolona z1, LiczbaZespolona z2) {
		double r = 0, i = 0;
		r = z1.getRe() - z2.getRe();
		i = z1.getIm() - z2.getIm();
		LiczbaZespolona z = new LiczbaZespolona(r, i);
		return z;
	}

	public LiczbaZespolona iloczyn(LiczbaZespolona z1, LiczbaZespolona z2) {
		double r = 0, i = 0;
		r = z1.getRe() * z2.getRe() - z1.getIm() * z2.getIm();
		i = z1.getIm() * z2.getRe() + z2.getIm() * z1.getRe();
		LiczbaZespolona z = new LiczbaZespolona(r, i);
		return z;
	}

	public double modul() {
		return Math.sqrt(re * re + im * im);
	}
}
